  <template>
  
  <el-container>
  <!-- 左边 -->
  <el-aside width="200px">
  
  <div class="userMsg">
  
  <div class="img">
  <img :src="user_pic" alt="" v-if='user_pic'>
  <img src="@/assets/logo.png" alt="" v-else>
  </div>
   <div class="username">用户： {{nickname || username}}</div>
  </div>
  <!-- menu -->
  <el-menu
      router
      :default-active="$route.path"
   
      background-color="#333"
      text-color="#fff"
      active-text-color="#ffd04b">
       <el-menu-item :index="item.indexPath" v-for="item in nochilden" :key="item.indexPath">
        <i :class=item.icon></i>
        <span slot="title">{{item.title}}</span>
      </el-menu-item>
      <el-submenu :index="subitem.indexPath" v-for="subitem in haschilden" :key="subitem.indexPath">
        <template slot="title">
          <i :class=subitem.icon></i>
          <span>{{subitem.title}}</span>
        </template>
         <el-menu-item :index="i.indexPath" v-for="i in subitem.children" :key="i.indexPath">
          <template slot="title">
          <i :class=i.icon></i>
          <span>{{i.title}}</span>
        </template>
         </el-menu-item>
        
      </el-submenu>
      
    </el-menu>


  </el-aside>
  <el-container>
    <el-header>
    <div>大 事 件</div>
    
    <div class="right">
    
    <div class="person">
    <el-dropdown>
   <span >
    个人中心<i class="el-icon-arrow-down el-icon--right"></i>
   </span>
   <el-dropdown-menu slot="dropdown">
    <el-dropdown-item icon="el-icon-tickets">基本资料</el-dropdown-item>
    <el-dropdown-item icon="el-icon-key">更换密码</el-dropdown-item>
    <el-dropdown-item icon="el-icon-s-custom">更换头像</el-dropdown-item>
   
  </el-dropdown-menu>
 </el-dropdown>

    </div>
    <div><i class="el-icon-switch-button" @click="qiut">退 出</i></div>
    </div>
    </el-header>
    <!-- main -->
    <el-main>
 <el-card>
   <router-view></router-view>
 </el-card>
    </el-main>
  </el-container>
</el-container>
 

</template>

<script>
import {userinfo,Menus} from '@/api/http'
import {mapGetters} from 'vuex'
export default {
  
  data() {
    return {
      menu:[],
      chartInstance:null
    }
  },
  computed:{
    ...mapGetters(['nickname','username','user_pic']),
    nochilden(){
 return  this.menu.filter(item =>!item.children );
   },
   haschilden(){
  return   this.menu.filter(item => item.children);
   },
  },
            methods: {
  
        
              qiut () {
                 var storage = localStorage;
                 storage.clear();
             
                this.$router.push('/login')
              },
      async  getMenus(){
            const res = await  Menus ()
            console.log(res) 
            console.log(res.data.data)
            this.menu=res.data.data
            this.$store.commit('getstateMenu',res.data.data)
            localStorage.setItem('Menu',res.data.data)
          },
            },
          created() {
            this.getMenus()
          
          },
           mounted () {
        this.initChart()
       
        // 绘制图表
        },
}
</script>

<style lang='less' scoped>
 .el-header {
  color: #fff;
  
    background-color: #333;
    text-align: center;
    line-height: 60px;
    display: flex;
    justify-content: space-between;
  }
  .right{
    display: flex;
    color: #fff;
    align-items: center;
    div{margin: 0 20px; cursor: pointer;}
    span{color: #fff;}
    .person{
      margin-left: -10px;
      
    }
  }
  .el-aside {
    color: #fff;
  
    background-color: #333;
    text-align: center;
    
   
  }
  
  .el-main {
    background-color: #E9EEF3;
     color: #fff;
    text-align: center;
  
  }
  
 .el-container {
    width: 100%;
    height: 100%;
  }
  .userMsg{
    margin-top: 20px;
   
    img{
      width: 50px;
      height: 50px;
      border-radius: 50%;
    }
    .img{
      display: flex;
      justify-content: space-around;
      align-items: center;
      width: 100%;
      height: 50px;
     img{
      text-align: center;
      border-radius: 50%;
     }
      box-sizing: border-box;
   
    }
  }
 .el-menu{
  border-right: none;
 }
 #main{
    width: 500px;
    height: 500px;
}
.username {
  width: 100%;
  margin-top: 10px;
  margin-left: -10px;
  overflow: hidden;

}
.el-dropdown-menu{
  
  width: 150px;
  background-color: #333;
  color: #fff;
}
.el-dropdown-item{
  color: #fff;
   background-color: #333;
}
</style>